<?php

namespace app\admin\controller\depot\async;

use app\common\controller\Backend;

/**
 * 供应商异步管理
 */
class Supplier extends Backend
{
    protected $model = null;
    protected $relationSearch = true;
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Depot.Supplier');
    }

    /**
     * 查看
     */
    public function index()
    {
      $this->request->filter(['strip_tags']);
      if ($this->request->isAjax())
      {
        if ($this->request->request('keyField'))
        {
            return $this->selectpage();
        }
        list($where, $sort, $order, $offset, $limit) = $this->buildparams();
        
        $total = $this->model
                ->where($where)
                ->order($sort, $order)
                ->count();

        $list = $this->model
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();

        $result = array("total" => $total, "rows" => $list);

        return json($result);
      }
      return $this->view->fetch();
    }
}